package org.jeecg.modules.filebank.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.filebank.entity.CrdFileBli;
import org.jeecg.modules.filebank.mapper.CrdFileBliMapper;
import org.jeecg.modules.filebank.service.ICrdFileBliService;
import org.jeecg.modules.filebank.vo.FileVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 文件库
 * @Author: jeecg-boot
 * @Date:   2020-05-15
 * @Version: V1.0
 */
@Service
public class CrdFileBliServiceImpl extends ServiceImpl<CrdFileBliMapper, CrdFileBli> implements ICrdFileBliService {

    @Autowired
    private  CrdFileBliMapper crdFileBliMapper;
    @Override
    public FileVo getFileVo() {
//        List<FileVo> fileVoList = new ArrayList<>();
//
//        QueryWrapper<CrdFileBli> crdFileBliQueryWrapper = new QueryWrapper<>();
//        crdFileBliQueryWrapper.eq("file_type",1);
//        crdFileBliQueryWrapper.eq("del_flag",0);
//        crdFileBliQueryWrapper.isNull("parent_id").orderByDesc("create_time");
//
//        List<CrdFileBli> crdFileBlis =  crdFileBliMapper.selectList(crdFileBliQueryWrapper);
//        if(!CollectionUtils.isEmpty(crdFileBlis)){
//            for (CrdFileBli crdFileBli : crdFileBlis) {
//                FileVo fileVo = new FileVo() ;
//                BeanUtils.copyProperties(fileVo,crdFileBli);
//                QueryWrapper<CrdFileBli> childQuery = new QueryWrapper<>();
//                childQuery.eq("file_type",1);
//                childQuery.eq("del_flag",0);
//                childQuery.eq("parent_id",crdFileBli.getId()).orderByDesc("create_time");
//                List<CrdFileBli> chilList = crdFileBliMapper.selectList(childQuery);
//
//               while (chilList !=null ){
//                   fileVo.setFileList(chilList);
//                   for (CrdFileBli fileBli : chilList) {
//                       childQuery.eq("del_flag",0);
//                       childQuery.eq("parent_id",crdFileBli.getId()).orderByDesc("create_time");
//                        chilList = crdFileBliMapper.selectList(childQuery)
//                   }
//
//               }
//            }
//        }
        return  null;
    }
}
